import request from './request'

/**
 * 点赞帖子
 * @param {string} postId - 帖子ID
 * @returns {Promise<Object>} - 包含点赞信息的响应
 */
export const likePost = async (postId) => {
  return request.post(`/posts/${postId}/like`)
}

/**
 * 取消点赞帖子
 * @param {string} postId - 帖子ID
 * @returns {Promise<Object>} - 响应结果
 */
export const unlikePost = async (postId) => {
  return request.delete(`/posts/${postId}/like`)
}

/**
 * 获取帖子的点赞列表
 * @param {string} postId - 帖子ID
 * @param {Object} params - 查询参数（如分页）
 * @returns {Promise<Array>} - 点赞列表
 */
export const fetchPostLikes = async (postId, params = {}) => {
  return request.get(`/posts/${postId}/likes`, { params })
}

/**
 * 点赞评论
 * @param {string} commentId - 评论ID
 * @returns {Promise<Object>} - 包含点赞信息的响应
 */
export const likeComment = async (commentId) => {
  return request.post(`/comments/${commentId}/like`)
}

/**
 * 取消点赞评论
 * @param {string} commentId - 评论ID
 * @returns {Promise<Object>} - 响应结果
 */
export const unlikeComment = async (commentId) => {
  return request.delete(`/comments/${commentId}/like`)
}